package com.dianjing.dianqun.service.dianpai;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import com.dianjing.dianqun.common.base.CrudService;
import com.dianjing.dianqun.dao.dianpai.DianPaiContentExtMapper;
import com.dianjing.dianqun.dao.dianpai.DianPaiContentMapper;
import com.dianjing.dianqun.model.DianPaiContent;
import com.dianjing.dianqun.model.DianPaiContentExt;

/**
 * @date : 2017年10月23日
 * 
 * @author: baoyongtao
 * 
 * @see :
 * 
 */

@Service
@Transactional(readOnly = true, isolation = Isolation.DEFAULT)
public class DianPaiContentService extends CrudService<DianPaiContentMapper, DianPaiContent> {

	@Autowired
	DianPaiContentMapper contentMapper;

	@Autowired
	DianPaiContentExtMapper contentExtMapper;

	public List<DianPaiContent> selectAllContent() {
		return contentMapper.selectAllContent();
	}

	/**
	 * 保存点拍得时候保存扩展内容
	 * 
	 * @param content
	 */
	@Transactional(readOnly = false, isolation = Isolation.DEFAULT)
	public void insertContentAndExt(DianPaiContent content) {
		contentMapper.insertSelective(content);
		DianPaiContentExt contentExt = content.getContentExt();
		contentExt.setContentId(content.getContentId());
		contentExtMapper.insertSelective(contentExt);
	}

	/**
	 * 根据用户查询点拍列表
	 * @param userId
	 * @return
	 */
	public List<DianPaiContent> selectContentByUserId(Integer userId) {
		return contentMapper.selectContentByUser(userId);
	}

}
